ldiv[divide two long integers]

Contents|Index|Previous|Next

ldiv
[divide two long integers]

    SYNOPSIS
    #include <stdlib.h> ldiv_t ldiv(long n, long d);

DESCRIPTION
ldiv divides n/d, returning quotient and remainder as two long integers in a structure, ldiv_t.

RETURNS
The result is represented with the following example.

typedef struct
{
long quot;
long rem;
} ldiv_t;

The example shows where the quot field represents the quotient, and rem represents the remainder.

For nonzero, d, if r=ldiv(n,d);, then n equals r.rem + d*r.quot.

To divide int rather than long values, use the similar function, div.

COMPLIANCE
ldiv is ANSI.

No supporting OS subroutines are required.